home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 3.1 KB | 160 lines | [TEXT/ttxt] |
- --<<<
-
- class BetterShadowedShapeSuper (TwoDPresenter)
- instance variables
- fill
- stroke:blackbrush
- shadowFill:(new brush color:bluecolor)
- shadowStroke:blackbrush
- shadowXoffset:5
- shadowYoffset:-5
- end
-
-
- class BetterShadowedShape (BetterShadowedShapeSuper)
- end
-
-
- method init self {class BetterShadowedShape} #rest args #key \
- target:(new Rect x2:50 y2:50) ->
- (
- local boundary := new Rect \
- x2:(target.width + abs (self.shadowXoffset)) \
- y2:(target.height + abs(self.shadowYoffset))
- apply NextMethod self boundary:boundary target:target args
- )
-
-
- method updateBoundary self {class BetterShadowedShape} ->
- (
- local target := self.target
- self.boundary := new Rect \
- x2:(target.width + abs (self.shadowXoffset)) \
- y2:(target.height + abs(self.shadowYoffset))
- )
-
-
-
-
- method heightSetter self {class BetterShadowedShape} value ->
- (
- self.target.height := value
- updateBoundary self
- notifyChanged self true
- )
-
- method widthSetter self {class BetterShadowedShape} value ->
- (
- self.target.width := value
- updateBoundary self
- notifyChanged self true
- )
-
- method heightGetter self {class BetterShadowedShape} ->
- (
- self.target.height
- )
-
- method widthGetter self {class BetterShadowedShape} ->
- (
- self.target.width
- )
-
- method fillSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- notifychanged self true
- value
- )
-
-
- method strokeSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- notifychanged self true
- value
- )
-
-
- method shadowfillSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- notifychanged self true
- true
- )
-
-
- method shadowStrokeSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- notifychanged self true
- value
- )
-
-
- method shadowXoffsetSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- updateBoundary self
- notifychanged self true
- value
- )
-
- method shadowYoffsetSetter self {class BetterShadowedShape} value ->
- (
- nextMethod self value
- updateBoundary self
- notifychanged self true
- value
- )
-
-
- method draw self {class BetterShadowedShape} surface clip ->
- (
- local xval := self.shadowXoffset
- local yval := self.shadowYoffset
- if (self.fill != undefined)
- do (
- local gTransform := self.transform
-
- -- fill the shadow
- local xvala, yvala
- xvala := if xval < 0 then 0 else xval
- yvala := if yval > 0 then yval else 0
- translate gTransform xvala yvala
- fill surface self.target clip gTransform self.shadowFill
- stroke surface self.target clip gTransform self.shadowStroke
-
- -- now draw the target
- translate gTransform (- xval) (- yval)
- fill surface self.target clip gTransform self.fill
- stroke surface self.target clip gTransform self.stroke
-
- -- restore the global transform
- xvala := if xval >= 0 then 0 else xvala := xval
- yvala := if yval <= 0 then yval else 0
- translate gTransform xvala yvala
- )
- )
-
-
- global w := new window
- w.height := 300
- w.width := 400
- show w
-
-
- global shape1 := new BetterShadowedShape \
- target:(new oval x2:100 y2:100)
-
-
- shape1.fill := new brush color:magentacolor
-
-
- shape1.x := 20
- shape1.y := 20
- prepend w shape1
- -->>>
-
-
-